<template>
	<view>
		<view class="label">
			<view class="label_text">设备ID</view>
			<view class="textinput flex-between">
				<input type="text" v-model="nameid" @input='inputChange' placeholder="输入ID" placeholder-class="phone" />
				<view class="flex" style="align-items: center;">
					<image class="img1" src="../../static/wallet/line.png" mode=""></image>
					<view class="text2" @tap="handleScanCode">
						<image src="../../static/wallet/sweep.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<view class="label">
			<view class="label_text">备注</view>
			<view class="textinput flex-between">
				<input type="text" v-model="remark" @input='inputChange' placeholder="输入备注" placeholder-class="phone" />
			</view>
		</view>
		<view class="label">
			<view class="label_text">选择分组</view>
			<view class="textinput flex-between" @click="showmodel=true">
				<span class="phone">{{group?group:'选择分组'}}</span>
				<view class="flex" style="align-items: center;">
					<image class="img2" src="../../static/wallet/down.png" mode=""></image>
				</view>
			</view>
		</view>
		<view :class="logining?'isbtn istext':'istext'" @click="logining?add():''">
			提交
		</view>
		<u-overlay :show="showmodel" @click="showmodel = false">
			<view class="model">
				<view class="model_name" @click="group='分组1'">分组1</view>
				<view class="model_line"></view>
				<view class="model_name" @click="showmodel=false">取消</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nameid: '',
				remark: '',
				logining: false,
				group: '',
				showmodel: false
			}
		},
		methods: {
			inputChange() {
				const {
					id,
					remark,
					group
				} = this
				if (id !== '' && remark !== '') {
					this.logining = true
				} else {
					this.logining = false
				}
			},
			handleScanCode() {
				let _that = this
				//#ifdef H5
				this.$fun.msg('H5暂不支持扫码！')
				//#endif
				// #ifndef H5
				uni.scanCode({
					success: function(res) {
						_that.nameid = res.result
					}
				});
				// #endif
			},
			add() {

			}
		}
	}
</script>

<style lang="scss" scoped>
	.label {
		width: 690rpx;
		box-sizing: border-box;
		margin: 0 auto 0;
		padding-top: 30rpx;

		&_text {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;
			line-height: 28rpx;
			text-align: left;
			font-style: normal;
		}

		.textinput {
			width: 690rpx;
			height: 80rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			padding: 0 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			margin-bottom: 30rpx;
			align-items: center;

			.text1 {
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
			}

			.text2 {
				font-weight: 500;
				font-size: 28rpx;
				color: #9999FF;

				image {
					width: 28rpx;
					height: 28rpx;
				}
			}
		}

		.img1 {
			width: 2rpx;
			height: 40rpx;
			margin: 0 20rpx;
		}

		.img2 {
			width: 28rpx;
			height: 28rpx;
		}

		.istipcol {
			color: #999999;
		}

		.phone,
		.password {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #CCCCCC;
			text-align: left;
			font-style: normal;
		}
	}

	.istext {
		width: 690rpx;
		height: 88rpx;
		border-radius: 44rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #CCCCCC;
		line-height: 88rpx;
		text-align: left;
		font-style: normal;
		text-align: center;
		margin: 90rpx auto 0;
	}

	.isbtn {
		background: $uni-color-primary;
		color: #FFFFFF;
	}

	.model {
		width: 750rpx;
		// height: 384rpx;
		background: #FFFFFF;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		position: fixed;
		bottom: 0;

		&_name {
			width: 750rpx;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-radius: 24rpx 24rpx 0rpx 0rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 30rpx;
			color: #333333;
		}

		&_line {
			width: 750rpx;
			height: 16rpx;
			background: #F1F3F6;
		}
	}
</style>